package com.pur.zsms.service.impl;

import java.io.InputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.annotation.Resource;

import net.sf.cglib.beans.BeanCopier;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pur.zsms.common.exception.GenericException;
import com.pur.zsms.common.support.PageController;
import com.pur.zsms.common.support.PaginationSupport;
import com.pur.zsms.common.util.ExcelReader;
import com.pur.zsms.common.util.PubFun;
import com.pur.zsms.common.vo.CommonType;
import com.pur.zsms.dao.ICashierDao;
import com.pur.zsms.dao.IDistributorDao;
import com.pur.zsms.dao.impl.CashierDaoImpl;
import com.pur.zsms.dao.impl.DistributorDaoImpl;
import com.pur.zsms.foodmanage.food.dao.IFoodDao;
import com.pur.zsms.foodmanage.food.po.FoodMaterPo;
import com.pur.zsms.foodmanage.food.po.FoodPo;
import com.pur.zsms.foodmanage.food.vo.FoodVo;
import com.pur.zsms.matermanage.mater.dao.IMaterDao;
import com.pur.zsms.matermanage.mater.po.MaterLevelBlPo;
import com.pur.zsms.matermanage.mater.po.MaterLevelPo;
import com.pur.zsms.matermanage.mater.po.MaterPo;
import com.pur.zsms.matermanage.mater.vo.MaterVo;
import com.pur.zsms.matermanage.mater.vo.MaterVoForSup;
import com.pur.zsms.matermanage.mater.vo.OrderDistributorMaterRealVo;
import com.pur.zsms.ordercustommanage.dao.ISelectFoodDao;
import com.pur.zsms.ordercustommanage.po.OrderCustFoodPo;
import com.pur.zsms.ordercustommanage.po.OrderCustPo;
import com.pur.zsms.ordercustommanage.po.OrderDistributorMaterRealPo;
import com.pur.zsms.ordercustommanage.po.OrderDistributorPo;
import com.pur.zsms.ordercustommanage.po.OrderSupplierMaterNeedPo;
import com.pur.zsms.ordercustommanage.po.OrderSupplierMaterPo;
import com.pur.zsms.ordercustommanage.po.OrderSupplierMaterRealPo;
import com.pur.zsms.ordercustommanage.po.OrderSupplierPo;
import com.pur.zsms.ordercustommanage.service.ISelectFoodService;
import com.pur.zsms.ordercustommanage.vo.OrderCustFoodVo;
import com.pur.zsms.ordercustommanage.vo.OrderCustVo;
import com.pur.zsms.ordercustommanage.vo.OrderDistributorVo;
import com.pur.zsms.ordercustommanage.vo.OrderStateVo;
import com.pur.zsms.ordercustommanage.vo.OrderSupplierMaterRealVo;
import com.pur.zsms.ordercustommanage.vo.OrderSupplierVo;
import com.pur.zsms.ordercustommanage.vo.SelectFoodVo;
import com.pur.zsms.ordercustommanage.vo.SelectMaterVo;
import com.pur.zsms.pmsnmanage.user.po.UserPo;
import com.pur.zsms.pmsnmanage.user.service.IUserService;
import com.pur.zsms.po.CashierOrderPo;
import com.pur.zsms.service.ICashierService;
import com.pur.zsms.service.IDistributorService;
import com.pur.zsms.shopmanage.dao.IShopDao;
import com.pur.zsms.supplier.dao.SupplierDao;
import com.pur.zsms.supplier.dao.SupplierOrderDao;
import com.pur.zsms.supplier.po.ShopSupplierTypePo;
import com.pur.zsms.supplier.po.SupplierPo;
import com.pur.zsms.vo.CashierOrderDetailVo;
import com.pur.zsms.vo.CashierOrderVo;
import com.pur.zsms.weixin.service.IWeixinService;

@Service("cashierService")
public class CashierServiceImpl implements ICashierService {

	final String dayNames[] = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };

	@Resource(name = "cashierDao")
	private ICashierDao cashierDao;

	@Resource(name = "foodDao")
	private IFoodDao foodDaoImpl;

	String msg = "";

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public PaginationSupport cashierListForShop(PageController pageController, CashierOrderVo vo) throws GenericException {
		return cashierDao.cashierListForShop(pageController, vo);

	}

	public PaginationSupport cashierListDetailForShop(PageController pageController, CashierOrderDetailVo vo) throws GenericException {
		return cashierDao.cashierListDetailForShop(pageController, vo);

	}

	public PaginationSupport findFoodCashier(PageController pageController, FoodVo vo) throws GenericException {
		return cashierDao.findFoodCashier(pageController, vo);
	}

	public PaginationSupport cashierListStatisticsForShop(PageController pageController, CashierOrderDetailVo vo) throws GenericException {
		return cashierDao.cashierListStatisticsForShop(pageController, vo);
	}

	public PaginationSupport cashierListStatisticsDetailForShop(PageController pageController, CashierOrderDetailVo vo) throws GenericException {
		return cashierDao.cashierListStatisticsDetailForShop(pageController, vo);
	}

	public List<CashierOrderPo> getCashierOrderPo(CashierOrderVo c) throws GenericException {
		return cashierDao.getCashierOrderPo(c);
	}

	public void deleteFoodCashier(FoodVo c) throws GenericException {
		// foodDaoImpl.listFoodByFoodName(c);
		FoodPo po = foodDaoImpl.getFoodPo(c).get(0);
		po.setIs_active(1);
		foodDaoImpl.updateFood(po);
	}

	public void updateFoodCashier(FoodVo c) throws GenericException {
		FoodPo po = foodDaoImpl.getFoodPo(c).get(0);
		po.setFoodName(c.getFoodName());
		po.setFoodType(c.getFoodType());
		po.setFoodValue(c.getFoodValue());
		foodDaoImpl.updateFood(po);
	}

}
